import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;

import stockQuoteGetter.*;



public class Main
{
	
	public static void commandLineInterface (String message) throws MalformedURLException
	{
		StockQuoteGetter sqg = new StockQuoteGetter ();
		BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
		String exit = "exit";
		String input = "";
		System.out.println(message);
		double quoteVal = 0;
		
		while(true)
		{
			System.out.print(">");
			try
			{
				input = new String();
				input = cin.readLine();
				
				if(input.equals(exit))
					break;
				
				quoteVal = sqg.getQuote(input);
				
				System.out.println(quoteVal);
				
			} 
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		try
		{
			Main.commandLineInterface("Please enter a ticker symbol or 'exit' to quit:");
			System.out.println("bye!");
		} 
		catch (MalformedURLException e)
		{
			e.printStackTrace();
		}
	}

}
